<template>
    <a-modal :maskClosable="true" :title="title" :visible="visible" width=800 @cancel="cancel" @ok="handleOk">
        <a-card :bordered="false">
            <!-- 查询区域 -->
            <div class="table-page-search-wrapper">
                <a-form layout="inline" @keyup.enter.native="searchQuery">
                    <a-row :gutter="24">
                        <a-col :md="6" :sm="8">
                            <a-form-item label="单位简称">
                                <a-input placeholder="请输入单位简称" v-model="queryParam.orgCode"></a-input>
                            </a-form-item>
                        </a-col>
                        <a-col :md="6" :sm="8">
                            <a-form-item label="系统简称">
                                <a-input placeholder="请输入系统简称"
                                         v-model="queryParam.systemCode"></a-input>
                            </a-form-item>
                        </a-col>
                        <template v-if="toggleSearchStatus">
                            <a-col :md="6" :sm="8">
                                <a-form-item label="单位全称">
                                    <a-input placeholder="请输入单位全称" v-model="queryParam.orgName"></a-input>
                                </a-form-item>
                            </a-col>
                        </template>
                        <a-col :md="6" :sm="8">
                            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                                <a @click="handleToggleSearch" style="margin-left: 8px">
                                    {{ toggleSearchStatus ? '收起' : '展开' }}
                                    <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                                </a>
                            </span>
                        </a-col>

                    </a-row>
                </a-form>
            </div>
            <!-- 查询区域-END -->
            <!--用户列表-->
            <a-table
                    ref="table"
                    size="small"
                    rowKey="id"
                    :columns="columns"
                    bordered
                    :dataSource="dataSource"
                    :pagination="ipagination"
                    :loading="loading"
                    :rowSelection="rowSelection"
                    class="j-table-force-nowrap"
                    @change="handleTableChange"
            >
            </a-table>
        </a-card>


    </a-modal>
</template>

<script>
    import {JeecgListMixin} from '@/mixins/JeecgListMixin'

    export default {
        name: 'ExosystemSelectPop',
        mixins: [JeecgListMixin],
        components: {},
        data() {
            return {
                visible: false,
                title: '',
                columns: [
                    {
                        title: '#',
                        dataIndex: '',
                        key: 'rowIndex',
                        width: 60,
                        align: 'center',
                        customRender: function (t, r, index) {
                            return parseInt(index) + 1
                        }
                    },
                    {
                        title: '系统简称',
                        align: 'center',
                        dataIndex: 'systemCode'
                    },
                    {
                        title: '系统全称',
                        align: 'center',
                        dataIndex: 'systemName'
                    },
                    {
                        title: '单位简称',
                        align: 'center',
                        dataIndex: 'orgCode'
                    },
                    {
                        title: '单位全称',
                        align: 'center',
                        dataIndex: 'orgName'
                    },

                ],
                defQueryParam: {enabled: '1'},
                url: {
                    list: '/msi/msiRegisterExosystem/list',
                },
            }
        },
        computed: {
            rowSelection() {
                return {
                    //type: 'checkbox',
                    type: 'radio',
                    selectedRowKeys: this.selectedRowKeys,
                    onChange: (selectedRowKeys, selectedRows) => {
                        this.onSelectChange(selectedRowKeys, selectedRows)
                    },
                }
            }
        },
        methods: {
            hide() {
                this.visible = true
                this.queryParam = this.defQueryParam
                this.loadData()
                this.onClearSelected()
            },
            cancel() {
                this.visible = false
            },
            handleOk() {
                const that = this
                let selectionRows = this.selectionRows
                if (selectionRows.length == 0) {
                    this.$message.error('尚未选择任何明细')
                }
                this.$emit('ok', selectionRows)
                this.visible = false
            },
            searchQuery() {
                this.queryParam = Object.assign({}, this.defQueryParam, this.queryParam)
                this.loadData(1);
            },
            searchReset() {
                this.queryParam = this.defQueryParam
                this.loadData(1);
            },
        }
    }
</script>

<style scoped>
</style>
